#include "ScreenOverlayNode.h"

namespace ds {

ScreenOverlayNode::ScreenOverlayNode(const std::string& materialName) : Node("ScreenOverlay",materialName) {
	buffer = new TransformedVertexBuffer(D3DPT_TRIANGLESTRIP, 4 ,true);	
	buffer->clear();
	float u1,u2,v1,v2;
	u1 = v1 = 0.0f;
	u2 = v2 = 1.0f;
	int width = gEngine->getWidth();
	int height = gEngine->getHeight();	
	buffer->addVertex(      - 0.5f,        - 0.5f,0.0f,u1,v1);
	buffer->addVertex(width - 0.5f,        - 0.5f,0.0f,u2,v1);
	buffer->addVertex(      - 0.5f, height - 0.5f,0.0f,u1,v2);
	buffer->addVertex(width - 0.5f, height - 0.5f,0.0f,u2,v2);
	buffer->createBuffer();	
}

ScreenOverlayNode::~ScreenOverlayNode() {
}

void ScreenOverlayNode::prepareRendering() {
	buffer->prepareData();
}

void ScreenOverlayNode::draw() {
	buffer->render(2);
}

};
